// 定义语句块
// 定义语句块下面对应的代码块
// 定义块

const path = require('path');
const staticImg = path.join(__dirname, 'static');

 function ArduinoUnoBlocks (Blockly) {
    var color_sensor = '#28BFE6';
    var color_do = '#FF0000';
    var color_display = '#f59057';
    var color_base = '#179b73';

    // var color_display = "#FF6680";
    // var color_do = '#6067EB';
    var base_color = '#179b73';
    var color_serial = '#FF4482';
// 	    Blockly.Blocks.control_setup_loop = {
//     /**
//      * Block for if-else.
//      * @this Blockly.Block
//      */
//     init: function () {
//         this.jsonInit({
//             type: 'control_setup_loop',
//             message0: '',
//             message1: Blockly.Msg.BOOT_SETUP,
//             message2: '%1 ',
//             message3: 'loop',
//             message4: '%1',
//             args0: [],
//             args1: [],
//             args2: [
//                 {
//                     type: 'input_statement',
//                     name: 'SUBSTACK0'
//                 }
//             ],
//             args3: [],
//             args4: [
//                 {
//                     type: 'input_statement',
//                     name: 'SUBSTACK2'
//                 }
//             ],
//             category: Blockly.Categories.control,
//             extensions: ['colours_arduino', 'scratch_extension']
//         });
//     }
// };

//motordriverboard初始化
Blockly.Blocks.md_mdinit = {
        init:function(){
          this.setColour("#0097A7");
          this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_MOTORDRIVERBOARDINIT)
			.appendField(new Blockly.FieldDropdown([
    ['V3', "3"],
    ['V4', "4"],
    ['V5', "5"],
  ]),"version")
          this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
        }
        };
		//串口波特率
Blockly.Blocks.serialbeginsss = {
init:function(){
this.setColour("#0097A7");
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVEROARD_BAUDRATE)
.appendField(new Blockly.FieldDropdown([
    ['4800', "4800"],
    ['9600', "9600"],
    ['38400', "38400"],
    ['57600', "57600"],
    ['115200', "115200"],
  ]),"serialbeginsssss")
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//串口打印字符
Blockly.Blocks.serialprintsss = {
init:function(){
this.setColour("#0097A7");
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVEROARD_PRINLNTSTRING)
   this.appendValueInput("serialprintssss", String)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//串口打印数字
Blockly.Blocks.serialprintnum1sss = {
init:function(){
this.setColour("#0097A7");
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVEROARD_PRINLNTNUM)
   this.appendValueInput("serialprintsssss", Number)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//舵机初始化
Blockly.Blocks.md_servoinit = {
init:function(){
this.setColour("#0097A7");
this.appendDummyInput("")
.appendField(Blockly.Msg.MOTORDRIVEROARD_SERVOINIT)
  .appendField(new Blockly.FieldDropdown([
                      ['1', "1"],
                      ['2', "2"],
                      ['3', "3"],
                      ['4', "4"],
                      ['5', "5"],
                      ['6', "6"],
                      ['7', "7"],
                      ['8', "8"],
      ]),"servoports")
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//舵机角度
Blockly.Blocks.md_servodegree = {
init:function(){
this.setColour("#0097A7");
this.appendDummyInput("")
.appendField(Blockly.Msg.MOTORDRIVEROARD_SERVOINITS)
  .appendField(new Blockly.FieldDropdown([
                      ['1', "1"],
                      ['2', "2"],
                      ['3', "3"],
                      ['4', "4"],
                      ['5', "5"],
                      ['6', "6"],
                      ['7', "7"],
                      ['8', "8"],
      ]),"servoportss")
.appendField(Blockly.Msg.MOTORDRIVEROARD_SERVODEGREE)
   this.appendValueInput("servodegrees", Number)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
      //直流电机初始化
      Blockly.Blocks.md_dcmotorinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_DCMOTORINIT)
			.appendField(new Blockly.FieldDropdown([
                      ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]),"dcmotorports")
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
 //直流电机方向速度
          Blockly.Blocks.md_dcmotorspeed = {
            init:function(){
              this.setColour("#0097A7");
              this.appendDummyInput("")
                .appendField(Blockly.Msg.MOTORDRIVEROARD_DCMOTORINITS)
                 .appendField(new Blockly.FieldDropdown([
                     ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]),"dcmotorportss")
	                  .appendField(Blockly.Msg.MOTORDRIVEROARD_DCMOTORDIRECTION)
                 .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_POSITIVE, "FORWARD"],
                      [Blockly.Msg.MOTORDRIVEROARD_NEGATIVE, "BACKWARD"],
      ]),"dcmotordirections")
	              .appendField(Blockly.Msg.MOTORDRIVEROARD_DCMOTORDSPEED)
   this.appendValueInput("dcmotorspeeds", Number)
              this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
            }
            };
	 //停止直流电机
      Blockly.Blocks.md_stodcpmotor = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_STOPDCMOTOR)
			.appendField(new Blockly.FieldDropdown([
                      ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]),"dcmotorportsss")
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
 //编码电机初始化
      Blockly.Blocks.md_enmotorinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_ENMOTORINIT)
			.appendField(new Blockly.FieldDropdown([
                      ['ENCODER1', "1"],
                      ['ENCODER2', "2"],
      ]),"enmotorports")
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
 //编码电机方向速度
           Blockly.Blocks.md_enmotorspeed = {
            init:function(){
              this.setColour("#0097A7");
              this.appendDummyInput("")
                .appendField(Blockly.Msg.MOTORDRIVEROARD_ENMOTORINITS)
                 .appendField(new Blockly.FieldDropdown([
                     ['ENCODER1', "1"],
                      ['ENCODER2', "2"],
      ]),"enmotorportss")
	                  .appendField(Blockly.Msg.MOTORDRIVEROARD_ENMOTORDIRECTION)
                 .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_POSITIVE, "FORWARD"],
                      [Blockly.Msg.MOTORDRIVEROARD_NEGATIVE, "BACKWARD"],
      ]),"enmotordirections")
	              .appendField(Blockly.Msg.MOTORDRIVEROARD_ENMOTORDSPEED)
   this.appendValueInput("enmotorspeeds", Number)
              this.setPreviousStatement(true,null);
            this.setNextStatement(true,null);
          this.setTooltip('');
            }
            };
	 //停止编码电机
      Blockly.Blocks.md_stopenmotor = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_STOPENMOTOR)
			.appendField(new Blockly.FieldDropdown([
                     ['ENCODER1', "1"],
                      ['ENCODER2', "2"],
      ]),"enmotorportsss")
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	//步进电机初始化，每转步数
	 Blockly.Blocks.md_stepmotorinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_STEPMOTORINIT)
			.appendField(new Blockly.FieldDropdown([
                      ['Steper1', "1"],
                      ['Steper2', "2"],
      ]),"stepmotorports")
	  .appendField(Blockly.Msg.MOTORDRIVEROARD_STEPSPERROUND)
   this.appendValueInput("stepsperround", Number)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	//步进电机速度，步数
	 Blockly.Blocks.md_stepmotorspeed = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_STEPMOTORINITS)
			.appendField(new Blockly.FieldDropdown([
                      ['Steper1', "1"],
                      ['Steper2', "2"],
      ]),"stepmotorportsS")
	     .appendField(Blockly.Msg.MOTORDRIVEROARD_STEPMOTORDIRECTION)
                 .appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_POSITIVE, "1"],
                      [Blockly.Msg.MOTORDRIVEROARD_NEGATIVE, "2"],
      ]),"stepmotordirections")
	  .appendField(Blockly.Msg.MOTORDRIVEROARD_TOTALSTEPS)
   this.appendValueInput("totalstep", Number)
    this.appendDummyInput("")
   .appendField(Blockly.Msg.MOTORDRIVEROARD_STEPSPEED)
   this.appendValueInput("stepmotorspeed", Number)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	  //停止步进电机
	      Blockly.Blocks.md_stopstepper = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_STOPSTEPPERMOTOR)
			.appendField(new Blockly.FieldDropdown([
                     ['Steper1', "1"],
                      ['Steper2', "2"],
      ]),"stepmotorportsSs")
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	//rgb初始化
	  Blockly.Blocks.md_rgbinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_RGBINIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	 //rgb颜色
	  	  Blockly.Blocks.md_rgbcolor = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_RGB)
			.appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_RGBALL, "(E_RGB_INDEX)0"],
                      [Blockly.Msg.MOTORDRIVEROARD_RGBLEFT, "(E_RGB_INDEX)2"],
                      [Blockly.Msg.MOTORDRIVEROARD_RGBRIGHT, "(E_RGB_INDEX)1"],
      ]),"RGBPOSITION")
	  .appendField(Blockly.Msg.MOTORDRIVEROARD_RGBCOLOR)
    this.appendValueInput("COLOR", Number)
	  this.appendDummyInput("")
			 .appendField(Blockly.Msg.MOTORDRIVEROARD_RGBBRIGHTNESS)
			 this.appendValueInput("rgbbrightness", Number)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	  //rgb颜色 2
	  	  Blockly.Blocks.md_rgbcolor2 = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_RGB)
			.appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_RGBALL, "(E_RGB_INDEX)0"],
                      [Blockly.Msg.MOTORDRIVEROARD_RGBLEFT, "(E_RGB_INDEX)1"],
                      [Blockly.Msg.MOTORDRIVEROARD_RGBRIGHT, "(E_RGB_INDEX)2"],
      ]),"RGBPOSITION")
      this.appendValueInput("COLOR", Number)
			 this.appendDummyInput("")
			 .appendField(Blockly.Msg.MOTORDRIVEROARD_RGBBRIGHTNESS)
			 this.appendValueInput("rgbbrightness2", Number)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
		//红外接收初始化
		 Blockly.Blocks.md_irinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_IRINIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	  //红外是否按下
	  Blockly.Blocks.md_isirremote = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_IFIRREMOTEPRESSED)
		//.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_ultrasonic.png", 38, 32))
		 this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
          this.setOutput(true, 'Boolean');
        this.setTooltip('');
  }
};
		//emakefun红外遥控按下
				 Blockly.Blocks.md_irpress = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_IRPRESS)
						.appendField(new Blockly.FieldDropdown([
              ['A', "EM_IR_KEYCODE_A"],
              ['B', "EM_IR_KEYCODE_B"],
              ['C', "EM_IR_KEYCODE_C"],
              ['D', "EM_IR_KEYCODE_D"],
              ['↑', "EM_IR_KEYCODE_UP"],
              ['+', "EM_IR_KEYCODE_PLUS"],
              ['←', "EM_IR_KEYCODE_LEFT"],
              ['OK', "EM_IR_KEYCODE_OK"],
              ['→', "EM_IR_KEYCODE_RIGHT"],
              ['0', "EM_IR_KEYCODE_0"],
              ['↓', "EM_IR_KEYCODE_DOWN"],
              ['-', "EM_IR_KEYCODE_REDUCE"],
              ['1', "EM_IR_KEYCODE_1"],
              ['2', "EM_IR_KEYCODE_2"],
              ['3', "EM_IR_KEYCODE_3"],
              ['4', "EM_IR_KEYCODE_4"],
              ['5', "EM_IR_KEYCODE_5"],
              ['6', "EM_IR_KEYCODE_6"],
              ['7', "EM_IR_KEYCODE_7"],
              ['8', "EM_IR_KEYCODE_8"],
              ['9', "EM_IR_KEYCODE_9"],


      ]),"irpress")
 this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
          this.setOutput(true, 'Boolean');
        this.setTooltip('');
        }
      };
      //普通红外遥控按下
           Blockly.Blocks.md_irpress2 = {
          init:function(){
          this.setColour("#0097A7");
          this.appendDummyInput("")
              .appendField(Blockly.Msg.MOTORDRIVEROARD_IRPRESS2)
              .appendField(new Blockly.FieldDropdown([

                        ['1', "IR_KEYCODE_1"],
                        ['2', "IR_KEYCODE_2"],
                        ['3', "IR_KEYCODE_3"],
                        ['4', "IR_KEYCODE_4"],
                        ['5', "IR_KEYCODE_5"],
                        ['6', "IR_KEYCODE_6"],
                        ['7', "IR_KEYCODE_7"],
                        ['8', "IR_KEYCODE_8"],
                        ['9', "IR_KEYCODE_9"],
                        ['0', "IR_KEYCODE_0"],
                        ['*', "IR_KEYCODE_STAR"],
                        ['#', "IR_KEYCODE_POUND"],
                        ['↑', "IR_KEYCODE_UP"],
                        ['↓', "IR_KEYCODE_DOWN"],
                        ['ok', "IR_KEYCODE_OK"],
                        ['←', "IR_KEYCODE_LEFT"],
                        ['→', "IR_KEYCODE_RIGHT"],

        ]),"irpress2")
   this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
            this.setOutput(true, 'Boolean');
          this.setTooltip('');
          }
        };
		//蜂鸣器初始化
		 Blockly.Blocks.md_buzzerinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_BUZZERINIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	//蜂鸣器播放
			 Blockly.Blocks.md_buzzerplay = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_BUZZERPLAY)
						.appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_CONNECT, "0"],
                      [Blockly.Msg.MOTORDRIVEROARD_DISCONNECT, "1"],
                      [Blockly.Msg.MOTORDRIVEROARD_BUTTON, "2"],
                      [Blockly.Msg.MOTORDRIVEROARD_MODE, "3"],
                      [Blockly.Msg.MOTORDRIVEROARD_SUPERRISE, "6"],
                      [Blockly.Msg.MOTORDRIVEROARD_OHOH, "7"],
                      [Blockly.Msg.MOTORDRIVEROARD_OHOH2, "8"],
                      [Blockly.Msg.MOTORDRIVEROARD_CUTE, "9"],
                      [Blockly.Msg.MOTORDRIVEROARD_HAPPY, "11"],
                      [Blockly.Msg.MOTORDRIVEROARD_SAD1, "14"],
                      [Blockly.Msg.MOTORDRIVEROARD_SAD2, "15"],

      ]),"buzzerplays")
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
		//超声波初始化
		 Blockly.Blocks.md_ulinit = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_ULINIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
		//超声波读取距离
		 Blockly.Blocks.md_ulplay = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_ULPLAY)
         this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
        }
      };
		//ps2初始化
		 Blockly.Blocks.md_ps2init = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2INIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
		//ps2键被按下
 Blockly.Blocks.md_ps2pressed = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2PRESSED)
         this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
          this.setOutput(true, 'Boolean');
        this.setTooltip('');
        }
      };
//ps2按下
 Blockly.Blocks.md_ps2press = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2PRESS)
				.appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_PS2UP, "16"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2DOWN, "64"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFT, "128"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHT, "32"],
                      ['△', "4096"],
                      ['○', "8192"],
                      ['×', "16384"],
                      ['□', "32768"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFT1, "1024"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFT2, "256"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFT3, "2"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHT1, "2048"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHT2, "512"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHT3, "4"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2SELECT, "1"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2START, "8"],
      ]),"ps2buttons")
         this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
          this.setOutput(true, 'Boolean');
        this.setTooltip('');
        }
      };
//ps2获取摇杆值
 Blockly.Blocks.md_ps2getrockervalue = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2GETROCKERVALUE)
			.appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFTX, "7"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFTY, "8"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHTX, "5"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHTY, "6"],
      ]),"ps2rockers")
         this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
        }
      };
//ps2获取摇角度
 Blockly.Blocks.md_ps2getrockervalue2 = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2GETROCKERVALUE2)
			.appendField(new Blockly.FieldDropdown([
                      [Blockly.Msg.MOTORDRIVEROARD_PS2LEFTANGLE, "LeftHart()"],
                      [Blockly.Msg.MOTORDRIVEROARD_PS2RIGHTANGLE, "RightHart()"],
      ]),"ps2rockerss")
	    this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2GETROCKERANGLE)
         this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
        }
      };
//读取ps2状态
 Blockly.Blocks.ps2status = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_PS2STATUS)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };

/*/nef初始化
 Blockly.Blocks.md_nrfinits = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFINIT)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
//nrf发送数据
 Blockly.Blocks.md_nrfsend = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFSEND)
			 this.appendDummyInput("")
			 .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFADDRESS)
   this.appendValueInput("address", String)
    this.appendDummyInput("")
   .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFDATA)
   this.appendValueInput("data", Number)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
//nrf接收数据
 Blockly.Blocks.md_nrfreceive = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFRECEIVE)
			 this.appendDummyInput("")
			 .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFADDRESSS)
   this.appendValueInput("address2", String)
        this.setPreviousStatement(true,null);
          this.setNextStatement(true,null);
        this.setTooltip('');
        }
      };
	  //nrf数据不为空
 Blockly.Blocks.md_nrfdataisnotnull = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFRECEIVEDATAISNOTNULL)
         this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
          this.setOutput(true, 'Boolean');
        this.setTooltip('');
        }
      };
//nrf数据
 Blockly.Blocks.md_nrfdata = {
        init:function(){
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVEROARD_NRFRECEIVEDATA)
         this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
          this.setOutput(true, 'Number');
        this.setTooltip('');
        }
      };
*/

//nrf发送数据
Blockly.Blocks.md_nrf24l01send = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01SENDDATA1);
			this.appendValueInput("address", String)
				.appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01ADDRESS1)
		this.appendValueInput("channel", Number)
		.appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01CHANNEL)
		this.appendValueInput("arr", String)
		.appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01DATA)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
  }
};
//nrf接收数据
Blockly.Blocks.md_nrf24l01rec = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01SENDDATA1);
			this.appendValueInput("address2", String)
				.appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01ADDRESS1)
		this.appendValueInput("channel2", Number)
		.appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01CHANNEL)
		this.appendValueInput("arr2", String)
		.appendField(Blockly.Msg.MOTORDRIVERBOARD_INITNRF24L01DATA2)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
  }
};
//创建数组
Blockly.Blocks.md_makearr = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_MAKEARR);
	this.appendValueInput("arrname", String)
		 this.appendDummyInput("")
       .appendField(Blockly.Msg.MOTORDRIVERBOARD_ARRSTYLE)
			.appendField(new Blockly.FieldDropdown([
                      ['byte', "byte"],
                      ['int', "int"],
                      ['char', "char"],
                      ['float', "float"],
                      ['double', "double"],
      ]), "srrstyle")
				.appendField(Blockly.Msg.MOTORDRIVERBOARD_ARRNUM)
		this.appendValueInput("arrnum", Number)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
  }
};
//数组的第几项
Blockly.Blocks.md_setarr = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_SETARR);
	this.appendValueInput("arrname2", String)
    this.appendDummyInput("")
	.appendField(Blockly.Msg.MOTORDRIVERBOARD_ARRNO)
	 this.appendDummyInput("")
		this.appendValueInput("arrno2", Number)
		this.appendDummyInput("")
		.appendField(Blockly.Msg.MOTORDRIVERBOARD_ARRNO2)
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
  }
};
//数组的第几项赋值
Blockly.Blocks.md_setarr2 = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_SETARR);
	this.appendValueInput("arrname22", String)
		 this.appendDummyInput("")
				.appendField(Blockly.Msg.MOTORDRIVERBOARD_ARRNO)
		this.appendValueInput("arrno22", Number)
		 this.appendDummyInput("")
		 		.appendField(Blockly.Msg.MOTORDRIVERBOARD_ARRNO3)
		this.appendValueInput("arrvalue", Number)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
  }
};
//nrf发送数据
Blockly.Blocks.md_nrf24l01send2 = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_SENDDATA2);
	this.appendValueInput("nrfdata2", String)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
  }
};
//是否发送成功？
Blockly.Blocks.md_nrf24l01send2isok = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISSEND);
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
  }
};
//是否接收到数据
Blockly.Blocks.md_nrf24l01send2isrec = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISREC);
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
  }
};
//nrf接收数据
Blockly.Blocks.md_nrf24l01rec2 = {
  init: function() {
    this.setColour("#0097A7");
    this.appendDummyInput("")
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_SENDDATA3);
	this.appendValueInput("nrfdata3", String)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
  }
};

//四驱车初始化
Blockly.Blocks.md_m4init = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
			.appendField(Blockly.Msg.MOTORDRIVERBOARD_M4INIT)
        this.appendDummyInput("")
       .appendField(Blockly.Msg.MOTORDRIVERBOARD_LEFTFORWARD)
			.appendField(new Blockly.FieldDropdown([
                     ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]), "M4Ports1")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_RIGHTFORWARD)
			.appendField(new Blockly.FieldDropdown([
                     ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]), "M4Ports2")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_LEFTBACKWARD)
			.appendField(new Blockly.FieldDropdown([
                     ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]), "M4Ports3")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_RIGHTBACKWARD)
			.appendField(new Blockly.FieldDropdown([
                     ['M1', "1"],
                      ['M2', "2"],
                      ['M3', "3"],
                      ['M4', "4"],
      ]), "M4Ports4")
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//前进
Blockly.Blocks.md_m4goforward = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4GOFORWARD)
        this.appendValueInput("m4speed1", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//后退
Blockly.Blocks.md_m4backforward = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4BACKFORWARD)
        this.appendValueInput("m4speed2", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//左转
Blockly.Blocks.md_m4turnleft = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4TURNLEFT)
        this.appendValueInput("m4speed3", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//右转
Blockly.Blocks.md_m4turnright = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4TURNRIGHT)
        this.appendValueInput("m4speed4", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//左自旋
Blockly.Blocks.md_m4turnlefts = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4TURNLEFTS)
        this.appendValueInput("m4speed33", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//右自旋
Blockly.Blocks.md_m4turnrights = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4TURNRIGHTS)
        this.appendValueInput("m4speed44", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//行驶角度
Blockly.Blocks.md_m4godegree = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4GODEGREE)
        this.appendValueInput("m4godegree", Number)
        this.appendDummyInput("")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4GOSPEED)
        this.appendValueInput("m4gospeed", Number)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//停止
Blockly.Blocks.md_m4stop = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_M4STOP)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
     //蓝牙初始化
Blockly.Blocks.md_bluetoothinit = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_BLUETOOTHINIT)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//接收蓝牙数据
Blockly.Blocks.md_receivedata = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
           // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_RECEIVEDATA)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//接收到了蓝牙数据
Blockly.Blocks.md_receiveddata = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_RECEIVEDDDATA)
        //.appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};

Blockly.Blocks.md_bluetoothKeyPress = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_BLUETOOTHPRESS)
           // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
            .appendField(new Blockly.FieldDropdown(
           [
               ["↑", "0x0008"],
               ["↓", "0x0020"],
               ["←", "0x0010"],
               ["→", "0x0004"],
			   ["green", "0x1000"],
               ["red", "0x2000"],
               ["blue", "0x4000"],
               ["pink", "0x8000"],
           ]), "BLUETOOTHKEY")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
Blockly.Blocks.md_bluetoothstyle = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_BLUETOOTHSTYLE)
            //.appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
           .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MOTORDRIVERBOARD_BLUETOOTHSTYLE_BUTTONS, "13"],
                [Blockly.Msg.MOTORDRIVERBOARD_BLUETOOTHSTYLE_DIRECTIONS, "5"],
           ]), "BLUETOOTHSTYLE")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
 Blockly.Blocks.md_bluetoothgetdegree = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_BLUETOOTHGETDEGREE)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
//nrf初始化
Blockly.Blocks.md_nrfinit = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFINIT)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        this.appendValueInput("nrfadd", String)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//nrf数据已准备
Blockly.Blocks.md_nrfdataready = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFDATAREADY)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
//定义接收数组
Blockly.Blocks.md_nrfvalue = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFVALUE)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        //this.appendValueInput("nrfadd", String)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//nrf接收数据
Blockly.Blocks.md_nrfgetdata = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFGETDATA)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        //this.appendValueInput("nrfadd", String)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//获取到nrf数据包？
Blockly.Blocks.md_nrfgetpackage = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFGETPACKAGE)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
//创建nrf数据类型对象
Blockly.Blocks.md_nrfnewob = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFNEWOB)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        //this.appendValueInput("nrfadd", String)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
    }
};
//nrf数据类型是？下拉框
Blockly.Blocks.md_nrfdatafun = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFDATAFUN)
			 .appendField(new Blockly.FieldDropdown(
           [
               [Blockly.Msg.MOTORDRIVERBOARD_NRFDIRECTION, "E_ROBOT_CONTROL_DIRECTION"],
               [Blockly.Msg.MOTORDRIVERBOARD_NRFSPEED, "E_ROBOT_CONTROL_SPEED"],
               [Blockly.Msg.MOTORDRIVERBOARD_NRFBUTTON, "E_BUTTON"],
           ]), "datafun")
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
//无线手柄按键按下？下拉框
Blockly.Blocks.md_nrfbuttons = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
             .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFBUTTONS)
		 .appendField(new Blockly.FieldDropdown(
           [
               ["L", "0x0080"],
               ["R", "0x0040"],
               ["↑", "BT_PAD_UP"],
			   ["↓", "BT_PAD_DOWN"],
               ["←", "BT_PAD_LEFT"],
               ["→", "BT_PAD_RIGHT"],
           ]), "nrfbuttons")
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
        this.setOutput(true, 'Boolean');
        this.setTooltip('');
    }
};
//nrf获取的角度
Blockly.Blocks.md_nrfgetdegree = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFGETDEGREE)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        //this.appendValueInput("nrfadd", String)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setOutput(true, 'Number');
        this.setTooltip('');
    }
}
//nrf获取的速度
Blockly.Blocks.md_nrfgetspeed = {
    init: function () {
        this.setColour("#0097A7");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MOTORDRIVERBOARD_NRFGETSPEED)
        // .appendField(new Blockly.FieldImage("../../media/panthertank/pt_bluetooth.png", 45, 38))
        //this.appendValueInput("nrfadd", String)
        //.appendField(new Blockly.FieldImage("../../media/MotorDriverBoard/md_irtracking.png", 38, 32))
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
        this.setOutput(true, 'Number');
        this.setTooltip('');
    }
};


//notis







//lcd配置地址
Blockly.Blocks.motorDriverBoard_20lcdinit = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_LCDINIT_ADDRESS)
    this.appendValueInput("lcdinits", Number)
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
  this.setTooltip('');
  }
};

//lcd光标
Blockly.Blocks.motorDriverBoard_20lcdposition = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_POSITION)
    this.appendValueInput("row", Number)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_ROW)
    this.appendValueInput("col", Number)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_COL)
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
  this.setTooltip('');
  }
};
//lcd打印
Blockly.Blocks.motorDriverBoard_20lcdprint = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_LCDPRINT)
    this.appendValueInput("lcdprints", String)
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
  this.setTooltip('');
  }
};
//lcd清屏
Blockly.Blocks.motorDriverBoard_20lcdclear = {
  init:function(){
  this.setColour(color_display);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/39.LCD_1602.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_LCDCLEAR)
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
  this.setTooltip('');
  }
};
//LED
Blockly.Blocks.motorDriverBoard_led = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/4.LED-Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_LED)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
    ['P9', "P9"],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"],
  ]),"led")
  .appendField(new Blockly.FieldDropdown([
    [Blockly.Msg.MOTORDRIVERBOARD_OPEN, "1"],
    [Blockly.Msg.MOTORDRIVERBOARD_CLOSE, "0"],
  ]),"status")
  this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
this.setTooltip('');
}
};

//激光发射传感器
Blockly.Blocks.motorDriverBoard_laser = {
init:function(){
  this.setColour(color_do);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/50-Laser Emission Module.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_LASER)
    .appendField(new Blockly.FieldDropdown([
      ['P1', "P1"],
      ['P2', "P2"],
      ['P3', "P3"],
      ['P4', "P4"],
      ['P9', "P9"],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"],
    ]),"laser")
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_OPEN, "1"],
      [Blockly.Msg.MOTORDRIVERBOARD_CLOSE, "0"],
    ]),"laserStatus")
    this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
  this.setTooltip('');
}
};
//声音传感器
Blockly.Blocks.motorDriverBoard_vioce = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/29.Sound-Sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_VIOCE)
  .appendField(new Blockly.FieldDropdown([
    ['P5', "P5"],
    ['P6', "P6"],
    ['P7', "P7"],
  ]),"phvioce")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READVIOCE);
this.appendDummyInput("") 
.appendField(new Blockly.FieldDropdown([
[Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "vioce.dpRead1()"],
[Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "vioce.aRead2()"],
]),"vioceValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//光敏传感器
Blockly.Blocks.motorDriverBoard_light = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/8.Photosensitive Sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_LIGHT)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
  ]),"phlight")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READLIGHT)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//触摸传感器
Blockly.Blocks.motorDriverBoard_touch = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/13.Touch-Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TOUCH)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
    ['P9', "P9"],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"],
  ]),"phtouch")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISTOUCH)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//按键传感器 motorDriverBoard_button
Blockly.Blocks.motorDriverBoard_button = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/14.Button - Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BUTTONMODEL)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
    ['P9', "P9"],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"],
  ]),"phbutton")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISBUTTON)
  .appendField(new Blockly.FieldDropdown([
    [Blockly.Msg.MOTORDRIVERBOARD_PRESS, "down"],
    [Blockly.Msg.MOTORDRIVERBOARD_RELEASE, "loosen"],
    [Blockly.Msg.MOTORDRIVERBOARD_LONGPRESS, "holdDown"],
  ]),"isButton")
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//热敏传感器
Blockly.Blocks.motorDriverBoard_thermosensitive = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/28.Thermal  sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_THERMOSENSITIVE)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
  ]),"thermosensitive")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_THERMOSENSITIVEREAD)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_ANALOG)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//火焰传感器
Blockly.Blocks.motorDriverBoard_fire = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/35.Flame-Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_FIRE)
    .appendField(new Blockly.FieldDropdown([
      ['P5', "P5"],
      ['P6', "P6"],
      ['P7', "P7"],
    ]),"fire")
      .appendField(
        new Blockly.FieldDropdown([
          [Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "aRead2()"],
          [Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "dpRead1()"],
        ]),"fireValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
  this.setTooltip('');
}
};

//避障传感器
Blockly.Blocks.motorDriverBoard_abstacle = {
init:function(){
    this.setColour(color_sensor);
    this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/avoidance sensor.svg", 84, 42))
      .appendField(Blockly.Msg.MOTORDRIVERBOARD_ABSTACLE)
      .appendField(new Blockly.FieldDropdown([
        ['P5', "P5"],
        ['P6', "P6"],
        ['P7', "P7"],
      ]),"abstaclePort")
        .appendField(
          new Blockly.FieldDropdown([
            [Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "aRead2()"],
            [Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "dpRead1()"],
          ]),"abstacleValue")
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setOutput(true, 'Number');
    this.setTooltip('');
  }
};

// //火焰传感器
// Blockly.Blocks.motorDriverBoard_isFire = {
//   init:function(){
//       this.setColour("#00B1AC");
//       this.appendDummyInput("")
//     .appendField(new Blockly.FieldImage(staticImg+"/35.Flame-Sensor.svg", 84, 42))
//         .appendField(Blockly.Msg.MOTORDRIVERBOARD_FIRE)
//         .appendField(new Blockly.FieldDropdown([
//           ['P5', "P5"],
//           ['P6', "P6"],
//           ['P7', "P7"],
//         ]),"fire")
//           .appendField(
//             new Blockly.FieldDropdown([
//               [Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "aRead2()"],
//               [Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "dRead2()"],
//             ]),"fireValue")
//     this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
//         this.setOutput(true, 'Number');
//       this.setTooltip('');
//     }
//   };
//土壤湿度传感器
Blockly.Blocks.motorDriverBoard_soil = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/26.Soit moisture Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_SOIL)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
  ]),"soil")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_ANALOG)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//雨滴传感器
Blockly.Blocks.motorDriverBoard_rain = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/30.Water  droplets Sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_RAIN)
  .appendField(new Blockly.FieldDropdown([
    ['P5', "P5"],
    ['P6', "P6"],
    ['P7', "P7"],
  ]),"rain")
  .appendField(new Blockly.FieldDropdown([
    [Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "aRead2()"],
    [Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "dpRead1()"],
  ]),"rainValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//水深传感器
Blockly.Blocks.motorDriverBoard_waterdeep = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/25.Water  depth  Sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_WATERDEEP)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"],
    ['P4', "P4"],
  ]),"waterdeep")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_ANALOG)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//碰撞传感器
Blockly.Blocks.motorDriverBoard_knockswitch = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/2.Collision   Sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_KNOCKSWITCH)
  .appendField(new Blockly.FieldDropdown([
    ['P1', "P1"],
    ['P2', "P2"],
    ['P3', "P3"], 
    ['P4', "P4"],
    ['P9', "P9"],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"],
  ]),"knockswitch")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_READKNOCKSWITCH)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//dht11
Blockly.Blocks.motorDriverBoard_dht11 = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/12.Temperature   and humidity  sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DHT)
  .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
  ]),"dht11")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READDHT)
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_TEMPERATURE, "temperature"],
      [Blockly.Msg.MOTORDRIVERBOARD_HUMIDITY, "humidity"],
    ]),"temhum")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//温度传感器初始化 motorDriverBoard_ds
Blockly.Blocks.motorDriverBoard_ds = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/3.DS18B20.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DS)
  .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
  ]),"ds")
  this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
  this.setTooltip('');
}
};


// //温度传感器获取温度
// Blockly.Blocks.motorDriverBoard_requestds = {
// init:function(){
//   this.setColour("#00B1AC");
//   this.appendDummyInput("")
//    .appendField(new Blockly.FieldImage(staticImg+"/3.DS18B20.svg", 84, 42))
//     .appendField(Blockly.Msg.MOTORDRIVERBOARD_REQUESTDS)
//     this.setPreviousStatement(true,null);
//       this.setNextStatement(true,null);
//     this.setTooltip('');
// }
// };
//温度传感器初始化 motorDriverBoard_ds
Blockly.Blocks.motorDriverBoard_lm35 = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/3.LM35 Sensor.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READDHT)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ]
    ]),"lm35")
    this.appendDummyInput("")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_LM35)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
    this.setOutput(true, 'Number');
    this.setTooltip('');
}
};

//温度传感器读取温度
Blockly.Blocks.motorDriverBoard_readds = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/3.DS18B20.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_READDS)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//气体传感器
Blockly.Blocks.motorDriverBoard_air = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/6.MQ  Gas  sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_AIR)
  .appendField(new Blockly.FieldDropdown([
    ['P5', "P5"],
    ['P6', "P6"],
    ['P7', "P7"],
  ]),"air")
  .appendField(new Blockly.FieldDropdown([
    [Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "aRead2()"],
    [Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "dpRead1()"],
  ]),"airValue")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//人体热释电传感器
Blockly.Blocks.motorDriverBoard_body = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/38.Human  Body-Sensor.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BODY)
  .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
  ]),"body")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_READBODY)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//循迹传感器
Blockly.Blocks.motorDriverBoard_track = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/9.Power.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TRACK)
  .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
  ]),"track")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_READTRACK)
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//mpu
Blockly.Blocks.motorDriverBoard_mpu = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/19.6-Axis （Gyro+Accelerometer）.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_MPU)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READMPU)
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_XAXIS, "GetGravity(BT_X)"],
      [Blockly.Msg.MOTORDRIVERBOARD_YAXIS, "GetGravity(BT_Y)"],
      [Blockly.Msg.MOTORDRIVERBOARD_ZAXIS, "GetGravity(BT_Z)"],
      [Blockly.Msg.MOTORDRIVERBOARD_ROLL, "GetRoll()"],
      [Blockly.Msg.MOTORDRIVERBOARD_PITCH, "GetPitch()"],
     
    ]),"mpu2")
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};

//红外发送
Blockly.Blocks.motorDriverBoard_irsend = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/20.Infrared emission Module.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_IRSENDPIN)
 .appendField(new Blockly.FieldDropdown([
  ['P1' , "P1" ],
  ['P2' , "P2" ],
  ['P3' , "P3" ],
  ['P4' , "P4" ],
  ['P9' , "P9" ],
  ['P10', "P10"],
  ['P11', "P11"],
  ['P12', "P12"]
]),"irsend")
  this.appendValueInput("irdata2", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_IRDATA)
 
  this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//普通遥控器按下
Blockly.Blocks.motorDriverBoard_irKeyPress = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/IR Remote Control.svg", 84, 42))
.appendField(Blockly.Msg.MOTORDRIVERBOARD_IRKEYPRESSPORT)
 .appendField(new Blockly.FieldDropdown([
  ['P9' , "P9" ],
  ['P10', "P10"],
  ['P11', "P11"],
  ['P12', "P12"]
 ]),"irKeyPort")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_NORMALIR)
.appendField(new Blockly.FieldDropdown([
  ['1', "IR_KEYCODE_1"],
  ['2', "IR_KEYCODE_2"],
  ['3', "IR_KEYCODE_3"],
  ['4', "IR_KEYCODE_4"],
  ['5', "IR_KEYCODE_5"],
  ['6', "IR_KEYCODE_6"],
  ['7', "IR_KEYCODE_7"],
  ['8', "IR_KEYCODE_8"],
  ['9', "IR_KEYCODE_9"],
  ['0', "IR_KEYCODE_0"],
  ['*', "IR_KEYCODE_STAR"],
  ['#', "IR_KEYCODE_POUND"],
  ['↑', "IR_KEYCODE_UP"],
  ['↓', "IR_KEYCODE_DOWN"],
  ['OK', "IR_KEYCODE_OK"],
  ['←', "IR_KEYCODE_LEFT"],
  ['→', "IR_KEYCODE_RIGHT"],
]),"irkey")
   this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//emakefun遥控器按下
Blockly.Blocks.motorDriverBoard_emakefunIrKeyPress = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/4-1.Emakefun IR Remote Control.svg", 84, 42))
.appendField(Blockly.Msg.MOTORDRIVERBOARD_IREMAKEFUNPORT)
 .appendField(new Blockly.FieldDropdown([
  ['P9' , "P9" ],
  ['P10', "P10"],
  ['P11', "P11"],
  ['P12', "P12"]
 ]),"irEmakefunPort")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_EMAKEFUNIR)
.appendField(new Blockly.FieldDropdown([
  ['1', "EM_IR_KEYCODE_1"],
  ['2', "EM_IR_KEYCODE_2"],
  ['3', "EM_IR_KEYCODE_3"],
  ['4', "EM_IR_KEYCODE_4"],
  ['5', "EM_IR_KEYCODE_5"],
  ['6', "EM_IR_KEYCODE_6"],
  ['7', "EM_IR_KEYCODE_7"],
  ['8', "EM_IR_KEYCODE_8"],
  ['9', "EM_IR_KEYCODE_9"],
  ['0', "EM_IR_KEYCODE_0"],
  ['A', "EM_IR_KEYCODE_A"],
  ['B', "EM_IR_KEYCODE_B"],
  ['C', "EM_IR_KEYCODE_C"],
  ['D', "EM_IR_KEYCODE_D"],
  ['+', "EM_IR_KEYCODE_PLUS"],
  ['-', "EM_IR_KEYCODE_REDUCE"],
  ['↑', "EM_IR_KEYCODE_UP"],
  ['↓', "EM_IR_KEYCODE_DOWN"],
  ['OK', "EM_IR_KEYCODE_OK"],
  ['←', "EM_IR_KEYCODE_LEFT"],
  ['→', "EM_IR_KEYCODE_RIGHT"],
]),"irEmakefunkey")
   this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};

//蜂鸣器播放选择声音
Blockly.Blocks.motorDriverBoard_buzzerplay2 = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/7.Passlve  Buzzer Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BUZZERPLAY_PIN2)
    .appendField(new Blockly.FieldDropdown([
      ['P1' , "P1" ],
      ['P2' , "P2" ],
      ['P3' , "P3" ],
      ['P4' , "P4" ],
      ['P9' , "P9" ],
      ['P10', "P10"],
      ['P11', "P11"],
      ['P12', "P12"]
    ]),"phBuzzerInitPort")
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BUZZERPLAY_PLAY)
  .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_CONNECTION, "S_connection"],
      [Blockly.Msg.MOTORDRIVERBOARD_DISCONNECTION, "S_disconnection"],
      [Blockly.Msg.MOTORDRIVERBOARD_BUTTONPUSHED, "S_buttonPushed"],
      [Blockly.Msg.MOTORDRIVERBOARD_MODE3, "S_mode3"],
      [Blockly.Msg.MOTORDRIVERBOARD_SURPRISE, "S_surprise"],
      [Blockly.Msg.MOTORDRIVERBOARD_OHOH, "S_OhOoh"],
      [Blockly.Msg.MOTORDRIVERBOARD_OHOH2, "S_OhOoh2"],
      [Blockly.Msg.MOTORDRIVERBOARD_CUDDLY, "S_cuddly"],
      [Blockly.Msg.MOTORDRIVERBOARD_HAPPY, "S_happy"],
      [Blockly.Msg.MOTORDRIVERBOARD_FART1, "S_sad1"],
      [Blockly.Msg.MOTORDRIVERBOARD_FART2, "S_sad2"],
      [Blockly.Msg.MOTORDRIVERBOARD_CALLPOLICE, "S_callPolice"],
      [Blockly.Msg.MOTORDRIVERBOARD_STOP, "S_stop"],
    ]),"motorDriverBoard_songs")
    this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BUZZERPLAY_SOND)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};




//红外接收
Blockly.Blocks.motorDriverBoard_irreceive = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/18.IR  Receiver.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_IRRECEIVE)
 .appendField(new Blockly.FieldDropdown([
  ['P9' , "P9" ],
  ['P10', "P10"],
  ['P11', "P11"],
  ['P12', "P12"]
 ]),"irreceive")
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISRECEIVED)
   this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//红外接收传感器接收的值
Blockly.Blocks.motorDriverBoard_irreceivedata = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/18.IR  Receiver.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_IRRECEIVEDATA)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//红外接收传感器接收下一个值
Blockly.Blocks.motorDriverBoard_irreceivenext = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/18.IR  Receiver.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_IRRECEIVENEXT)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//有源蜂鸣器 motorDriverBoard_buzzer
Blockly.Blocks.motorDriverBoard_buzzer = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/7.Passlve  Buzzer Module.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_PASSIVEBUZZER)
 .appendField(new Blockly.FieldDropdown([
  ['P1' , "P1" ],
  ['P2' , "P2" ],
  ['P3' , "P3" ],
  ['P4' , "P4" ],
  ['P9' , "P9" ],
  ['P10', "P10"],
  ['P11', "P11"],
  ['P12', "P12"]
 ]),"buzzer")
  this.appendValueInput("buzzers", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_HZ)
  this.appendValueInput("time", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TIME);
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};

//无源蜂鸣器 motorDriverBoard_buzzer
Blockly.Blocks.motorDriverBoard_buzzer1 = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/1.Buzzer  Module.svg", 84, 42))
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_BUZZER)
   .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
    ['P9' , "P9" ],
    ['P10', "P10"],
    ['P11', "P11"],
    ['P12', "P12"]
   ]),"passiveBuzzer")
    this.appendValueInput("play_time", Number)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_TIME);
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

//直流电机
Blockly.Blocks.motorDriverBoard_motor = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/21.Motor-Module.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_MOTOR)
 .appendField(new Blockly.FieldDropdown([
   ['P8', "P8"],
   ['P7', "P7"],
   ['P6', "P6"],
   ['P5', "P5"],
 ]),"motor")
 .appendField(new Blockly.FieldDropdown([
   [Blockly.Msg.MOTORDRIVERBOARD_FORWARD, "forward"],
   [Blockly.Msg.MOTORDRIVERBOARD_REVERSE, "reverse"],
 ]),"direction")
  this.appendValueInput("motorSpeed", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_SPEED)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};

//双电机驱动
Blockly.Blocks.motorDriverBoard_dcMotorDriver = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/51.High Speed Mini Motor Drive Board.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DCMOTOR_PIN)
  .appendField(new Blockly.FieldDropdown([
    ['P13', "P13"],
  ]),"driverPin")
  this.appendValueInput("phDcMotors1", Number)
  // .appendField(Blockly.Msg.MOTORDRIVERBOARD_DCMOTORSPEED1)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DCMOTORSPEED1)
  this.appendValueInput("phDcMotors2", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DCMOTORSPEED2)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//双电机速度
Blockly.Blocks.motorDriverBoard_dcMotorSpeed = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/51.High Speed Mini Motor Drive Board.svg", 84, 42))
   this.appendValueInput("phDcMotors1", Number)
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_DCMOTORSPEED1)
   this.appendValueInput("phDcMotors2", Number)
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_DCMOTORSPEED2)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};

//继电器
Blockly.Blocks.motorDriverBoard_relay = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/22.Relay-Module.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RELAY)
 .appendField(new Blockly.FieldDropdown([
  ['P1' , "P1" ],
  ['P2' , "P2" ],
  ['P3' , "P3" ],
  ['P4' , "P4" ],
  ['P9' , "P9" ],
  ['P10', "P10"],
  ['P11', "P11"],
  ['P12', "P12"]
 ]),"relay")
 .appendField(new Blockly.FieldDropdown([
   [Blockly.Msg.MOTORDRIVERBOARD_OPEN, "HIGH"],
   [Blockly.Msg.MOTORDRIVERBOARD_CLOSE, "LOW"],
 ]),"status2")
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//  tm1650数码管
Blockly.Blocks.motorDriverBoard_tm1650 = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1650)
 .appendField(new Blockly.FieldDropdown([
  ["P7", "P7"],
]),"tm1650Port")
 .appendField(new Blockly.FieldDropdown([
   [Blockly.Msg.MOTORDRIVERBOARD_OPEN, "displayOn()"],
   [Blockly.Msg.MOTORDRIVERBOARD_CLOSE, "displayOff()"],
   [Blockly.Msg.MOTORDRIVERBOARD_CLEAR, "clear()"],
 ]),"status3")
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1650数码管显示
Blockly.Blocks.motorDriverBoard_tm1650display = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
  this.appendValueInput("tm1650displays", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1650DISPLAY)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1650数码管显示小数点
Blockly.Blocks.motorDriverBoard_tm1650displaypoint = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/37.4-digit  7-segment.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1650DISPLAYPOINT)
 .appendField(new Blockly.FieldDropdown([
   ['1', "0"],
   ['2', "1"],
   ['3', "2"],
   ['4', "3"],
 ]),"tm1650displaypoint")
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1650DISPLAYPOINTNUM)
 .appendField(new Blockly.FieldDropdown([
   [Blockly.Msg.MOTORDRIVERBOARD_BRIGHT, "true"],
   [Blockly.Msg.MOTORDRIVERBOARD_EXTINCT, "false"],
 ]),"tm1650displaypointnum")
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637初始化
Blockly.Blocks.motorDriverBoard_tm1637 = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637)
 .appendField(new Blockly.FieldDropdown([
  ['P5', "P5"],
  ['P6', "P6"],
  ['P7', "P7"],
  ['P8', "P8"],
]),"tm1637")
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637设置亮度
Blockly.Blocks.motorDriverBoard_tm1637setlight = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
  this.appendValueInput("tm1637setlights", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637SETLIGHT)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637显示
Blockly.Blocks.motorDriverBoard_tm1637display = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
  this.appendValueInput("tm1637displays", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637DISPLAY)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637是否显示两点
Blockly.Blocks.motorDriverBoard_tm1637displayPoint = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637DISPLAYTIMEPOINT)
 .appendField(new Blockly.FieldDropdown([
   ["ON", "1"],
   ["OFF", "0"],
 ]),"tm1637displaypointnum")
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637显示时间
Blockly.Blocks.motorDriverBoard_tm1637displaytime = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637DISPLAYTIME)
  this.appendValueInput("tm1637displaytime1", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637DISPLAYTIME1)
  this.appendValueInput("tm1637displaytime2", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637DISPLAYTIME2)
  this.appendDummyInput("")
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//tm1637清屏
Blockly.Blocks.motorDriverBoard_tm1637clear = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/23.4-digit clock 7-segment.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_TM1637CLEAR)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//rgb
Blockly.Blocks.motorDriverBoard_rgb = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/10.RGB-Module.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGB)
 .appendField(new Blockly.FieldDropdown([
   ['P15', "P15"],
   ['P16', "P16"],
 ]),"rgb")
  this.appendValueInput("rgb1", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBNUM)
  this.appendValueInput("rgb2", Number)
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBLIGHT)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//rgb颜色
Blockly.Blocks.motorDriverBoard_rgbcolor = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/10.RGB-Module.svg", 84, 42))
.appendField(Blockly.Msg.MOTORDRIVERBOARD_RGB)
.appendField(new Blockly.FieldDropdown([
 ['P15', "P15"],
 ['P16', "P16"],
]),"rgb")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_DISPLAYCOLOR)
this.appendValueInput("COLOR", Number)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};

//rgb颜色
Blockly.Blocks.motorDriverBoard_ringRgbColorInit = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/RGB Light Ring.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBRING)
 .appendField(new Blockly.FieldDropdown([
  ['P5' , "P5" ],
  ['P6' , "P6" ],
  ['P7' , "P7" ],
  ['P8' , "P8" ],
 ]),"rgbRing")
 
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};

//rgb颜色亮度
Blockly.Blocks.motorDriverBoard_setRingRgbLight = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/RGB Light Ring.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_SETRGBRINGLIGHT)
 this.appendValueInput("rgbLight", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBRINGLIGHT)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};



//rgb颜色
Blockly.Blocks.motorDriverBoard_ringRgbColor = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/RGB Light Ring.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBRING1)
 this.appendValueInput("total", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBTOTAL)
 this.appendValueInput("start", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBSTART)
 this.appendValueInput("end", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBEND)
 this.appendValueInput("lightTime", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TIME)
 this.appendValueInput("COLOR", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBULTRASONICSETCOLORLED)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};


// 摇杆
Blockly.Blocks.motorDriverBoard_rock = {


init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/31.Rocker - Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_ROCK)


    .appendField(new Blockly.FieldDropdown([
      ['P16', "P16"]
    ]),"rock")
      .appendField(Blockly.Msg.MOTORDRIVERBOARD_READROCK)
      .appendField(new Blockly.FieldDropdown([
        [Blockly.Msg.MOTORDRIVERBOARD_ROCKLEFT, "rock.aRead3()==1023"],
        [Blockly.Msg.MOTORDRIVERBOARD_ROCKRIGHT, "rock.aRead3()==0"],
        [Blockly.Msg.MOTORDRIVERBOARD_ROCKUP, "rock.aRead4()==0"],
        [Blockly.Msg.MOTORDRIVERBOARD_ROCKDOWN, "rock.aRead4()==1023"],
        [Blockly.Msg.MOTORDRIVERBOARD_BUTTON, "rock.dRead5() == 0"],
        [Blockly.Msg.MOTORDRIVERBOARD_NOTBUTTON, "rock.dRead5() == 1"]
      ]),"rock2")
      this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};
//钢琴模块
Blockly.Blocks.motorDriverBoard_piano = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/33.Touch  Piano.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_PIANO)
 .appendField(new Blockly.FieldDropdown([
  ['P5', "P5"],
  ['P6', "P6"],
  ['P7', "P7"],
 ]),"piano")
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_PIANOPRESS)
 .appendField(new Blockly.FieldDropdown([
   ['1', "BS_KEYCODE_1"],
   ['2', "BS_KEYCODE_2"],
   ['3', "BS_KEYCODE_3"],
   ['4', "BS_KEYCODE_4"],
   ['5', "BS_KEYCODE_5"],
   ['6', "BS_KEYCODE_6"],
   ['7', "BS_KEYCODE_7"],
   ['8', "BS_KEYCODE_8"],
 ]),"piano2")
 this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
this.setOutput(true, 'Boolean');
this.setTooltip('');
}
};
//旋转电位器
Blockly.Blocks.motorDriverBoard_resistance = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/16.Rotary  potentiometer.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_RESISTANCE)
  .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
  ]),"resistance")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READRESISTANCE)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//滑动电位器
Blockly.Blocks.motorDriverBoard_slipresistance = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/32.Slide  Potentiometer.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_SLIPRESISTANCE)
  .appendField(new Blockly.FieldDropdown([
    ['P1' , "P1" ],
    ['P2' , "P2" ],
    ['P3' , "P3" ],
    ['P4' , "P4" ],
  ]),"slipresistance")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READSLIPRESISTANCE)
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
this.setTooltip('');
}
};
//红绿灯
Blockly.Blocks.motorDriverBoard_trafficlights = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/27.Water  ljght Module.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TRIFFICLIGHTS)
 .appendField(new Blockly.FieldDropdown([
   ['P15', "P15"],
   ['P16', "P16"],
 ]),"trafficlights")
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_TRIFFICLIGHTSRED)
 .appendField(new Blockly.FieldDropdown([
  [Blockly.Msg.MOTORDRIVERBOARD_BRIGHT, "1"],
  [Blockly.Msg.MOTORDRIVERBOARD_EXTINCT, "0"],
]),"trafficlights2")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_TRIFFICLIGHTSGREEN)
.appendField(new Blockly.FieldDropdown([
  [Blockly.Msg.MOTORDRIVERBOARD_BRIGHT, "1"],
  [Blockly.Msg.MOTORDRIVERBOARD_EXTINCT, "0"],
]),"trafficlights3")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_TRIFFICLIGHTSYELLOW)
 .appendField(new Blockly.FieldDropdown([
   [Blockly.Msg.MOTORDRIVERBOARD_BRIGHT, "1"],
   [Blockly.Msg.MOTORDRIVERBOARD_EXTINCT, "0"],
 ]),"trafficlights4")
 this.appendValueInput("lightTime", Number)
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_SHOWTIME)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//流水灯
Blockly.Blocks.motorDriverBoard_waterlights = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")

.appendField(new Blockly.FieldImage(staticImg+"/11.Running Water light.svg", 84, 42))


 .appendField(Blockly.Msg.MOTORDRIVERBOARD_WHATERLIGHTS)
 .appendField(new Blockly.FieldDropdown([
   ['1', "1"],
   ['2', "2"],
   ['3', "3"],
   ['4', "4"],
   ['5', "5"],
   ['6', "6"],
   ['7', "7"],
   ['8', "8"],
   ['9', "9"],
   ['10', "10"],
   ['11', "11"],
   ['12', "12"],
   ['13', "13"],
   ['14', "14"],
 ]),"waterlights")
 .appendField(new Blockly.FieldDropdown([
   [Blockly.Msg.MOTORDRIVERBOARD_BRIGHT, "1"],
   [Blockly.Msg.MOTORDRIVERBOARD_EXTINCT, "0"],
 ]),"waterlights1")
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//8x8点阵屏初始化
Blockly.Blocks.motorDriverBoard_max = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
 .appendField(Blockly.Msg.MOTORDRIVERBOARD_MAX)
 .appendField(new Blockly.FieldDropdown([
   ['P15', "P15"],
   ['P16', "P16"],
 ]),"max")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_MAXS)
 this.appendValueInput("maxs", Number)
this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};

// //点阵屏显示
// Blockly.Blocks.MAX7219_DisplayChar = {
//   init:function(){
//   this.setColour(color_display);
//    this.appendDummyInput("")
//      .appendField(Blockly.Msg.ARDUINO_MAXPRINT)
//      .appendField(new Blockly.FieldDropdown([
//       ['0', "0"],
//       ['1', "1"],
//       ['2', "2"],
//       ['3', "3"],
//       ['4', "4"],
//       ['5', "5"],
//       ['6', "6"],
//       ['7', "7"],
//       ['8', "8"],
//       ['9', "9"],
//       [Blockly.Msg.ARDUINO_MSMILE, "10"],
//     [Blockly.Msg.ARDUINO_MBIGSMILE, "11"],
//       [Blockly.Msg.ARDUINO_MHAHA, "12"],
//       [Blockly.Msg.ARDUINO_MHEART, "13"],
//       [Blockly.Msg.ARDUINO_MSURPRISE, "14"],
//       [Blockly.Msg.ARDUINO_MLITTLESURPRISE, "15"],
//       [Blockly.Msg.ARDUINO_MTONE, "16"],
//       [Blockly.Msg.ARDUINO_MTOOTH1, "17"],
//       [Blockly.Msg.ARDUINO_MTOOTH2, "18"],
//       [Blockly.Msg.ARDUINO_MLINE, "19"],
//       [Blockly.Msg.ARDUINO_MCONFUSED, "20"],
//     [Blockly.Msg.ARDUINO_MLINE2, "21"],
//       [Blockly.Msg.ARDUINO_MSAD1, "22"],
//       [Blockly.Msg.ARDUINO_MSAD2, "23"],
//       [Blockly.Msg.ARDUINO_MSAD3, "24"],
//       ['√', "25"],
//       ['×', "26"],
//       ['?', "27"],
//       [Blockly.Msg.ARDUINO_MLIGHT, "28"],
//       [Blockly.Msg.ARDUINO_MMOUTH, "29"],
//       [Blockly.Msg.ARDUINO_MMAD, "30"],

//     ]),"draw")
//   this.setPreviousStatement(true,null);
//    this.setNextStatement(true,null);
//   this.setTooltip('');
//   }
//   };


//8x8点阵屏单点亮或灭
Blockly.Blocks.motorDriverBoard_maxpoint = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))


.appendField(Blockly.Msg.MOTORDRIVERBOARD_MAXPRINT)
.appendField(new Blockly.FieldDropdown([
['0', "0"],
['1', "1"],
['2', "2"],
['3', "3"],
['4', "4"],
['5', "5"],
['6', "6"],
['7', "7"],
['8', "8"],
['9', "9"],
[Blockly.Msg.MOTORDRIVERBOARD_MSMILE, "10"],
[Blockly.Msg.MOTORDRIVERBOARD_MBIGSMILE, "11"],
[Blockly.Msg.MOTORDRIVERBOARD_MHAHA, "12"],
[Blockly.Msg.MOTORDRIVERBOARD_MHEART, "13"],
[Blockly.Msg.MOTORDRIVERBOARD_MSURPRISE, "14"],
[Blockly.Msg.MOTORDRIVERBOARD_MLITTLESURPRISE, "15"],
[Blockly.Msg.MOTORDRIVERBOARD_MTONE, "16"],
[Blockly.Msg.MOTORDRIVERBOARD_MTOOTH1, "17"],
[Blockly.Msg.MOTORDRIVERBOARD_MTOOTH2, "18"],
[Blockly.Msg.MOTORDRIVERBOARD_MLINE, "19"],
[Blockly.Msg.MOTORDRIVERBOARD_MCONFUSED, "20"],
[Blockly.Msg.MOTORDRIVERBOARD_MLINE2, "21"],
[Blockly.Msg.MOTORDRIVERBOARD_MSAD1, "22"],
[Blockly.Msg.MOTORDRIVERBOARD_MSAD2, "23"],
[Blockly.Msg.MOTORDRIVERBOARD_MSAD3, "24"],
['√', "25"],
['×', "26"],
['?', "27"],
[Blockly.Msg.MOTORDRIVERBOARD_MLIGHT, "28"],
[Blockly.Msg.MOTORDRIVERBOARD_MMOUTH, "29"],
[Blockly.Msg.MOTORDRIVERBOARD_MMAD, "30"],
]),"draw")


this.setPreviousStatement(true,null);
this.setNextStatement(true,null);
this.setTooltip('');
}
};
//8x8点阵屏点选
Blockly.Blocks.motorDriverBoard_x8leddisplay = {
init:function(){
this.setColour(color_display);
this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/24. 8x8.svg", 84, 42))
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_X8LEDDISPLAY)
   .appendField(new Blockly.LatticeAdapter(),"draws")

   this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
   this.setTooltip('');
 }
};

//手势传感器获取值
Blockly.Blocks.motorDriverBoard_handle_gesture = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_HANDLE_GESTURE)
        .appendField(new Blockly.FieldDropdown([
          [Blockly.Msg.MOTORDRIVERBOARD_GESTUREUP, "DIR_UP"],
          [Blockly.Msg.MOTORDRIVERBOARD_GESTUREDOWN, "DIR_DOWN"],
          [Blockly.Msg.MOTORDRIVERBOARD_GESTURELEFT, "DIR_LEFT"],
          [Blockly.Msg.MOTORDRIVERBOARD_GESTURERIGHT, "DIR_RIGHT"],
          [Blockly.Msg.MOTORDRIVERBOARD_GESTURENEAR, "DIR_NEAR"],
          [Blockly.Msg.MOTORDRIVERBOARD_GESTUREFAR, "DIR_FAR"],
        ]),"gestureStatus")

    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
 
}
};

//手势传感器初始化
Blockly.Blocks.motorDriverBoard_handleGestureInit = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_HANDLEGESTUREINIT)
  // this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
  this.setTooltip('');
  // this.setOutput(true, 'Boolean');
  // this.setTooltip('');
}
};

//手势传感器是否获取到手势
Blockly.Blocks.motorDriverBoard_gesture = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_GESTURE)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};

//手势传感器状态
Blockly.Blocks.motorDriverBoard_gestureStatus = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")

   .appendField(new Blockly.FieldImage(staticImg+"/17.Gesture  Recognition Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_GESTURESTATUS)
        this.setPreviousStatement(true,null);
        this.setNextStatement(true,null);
        this.setTooltip('');


}
};

//旋转编码器初始化
Blockly.Blocks.motorDriverBoard_ec11Init = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")


   .appendField(new Blockly.FieldImage(staticImg+"/15.Rotary  encoder Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_EC11IINTERFACE)
        .appendField(new Blockly.FieldDropdown([
          ["P15", "P15"],
          ["P16", "P16"],
         ]),"rotary")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_EC11INIT)
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);


  this.setTooltip('');
}
};

//旋转编码器按钮是否按下
Blockly.Blocks.motorDriverBoard_ec11ButtonPushDown = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/15.Rotary  encoder Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_EC11BUTTONPUSHDOWN)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');


  this.setTooltip('');
}
};

//旋转编码器数值
Blockly.Blocks.motorDriverBoard_ec11 = {
init:function(){
  this.setColour(base_color);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/15.Rotary  encoder Module.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_EC11)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
  this.setTooltip('');
}
};

//灰度传感器读值
Blockly.Blocks.motorDriverBoard_grayscale = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/46-Grayscale Sensor.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_GRAYSCALE)
        .appendField(new Blockly.FieldDropdown([
          ['P1' , "P1" ],
          ['P2' , "P2" ],
          ['P3' , "P3" ],
          ['P4' , "P4" ],
          ['P9' , "P9" ],
          ['P10', "P10"],
          ['P11', "P11"],
          ['P12', "P12"]
         ]),"grayscale")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_ANALOG)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);


  this.setOutput(true, 'Number');
  this.setTooltip('');
}
};

//震动传感器读值
Blockly.Blocks.motorDriverBoard_shock = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")

   .appendField(new Blockly.FieldImage(staticImg+"/47-Shock Sensor.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_SHOCK)
        .appendField(new Blockly.FieldDropdown([
          ['P5', "P5"],
          ['P6', "P6"],
          ['P7', "P7"],
          ['P8', "P8"],
         ]),"shockPin")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_READFIRE)
         .appendField(new Blockly.FieldDropdown([
          [Blockly.Msg.MOTORDRIVERBOARD_ANALOG, "aRead2()"],
          [Blockly.Msg.MOTORDRIVERBOARD_DIGITAL, "dpRead1()"]
         ]),"shockValue")
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
  this.setTooltip('');
}
};


//倾斜传感器 是否倾斜
Blockly.Blocks.motorDriverBoard_tilt = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/48-Tilt Switch Sensor.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_TILT)
        .appendField(new Blockly.FieldDropdown([
          ['P1' , "P1" ],
          ['P2' , "P2" ],
          ['P3' , "P3" ],
          ['P4' , "P4" ],
          ['P9' , "P9" ],
          ['P10', "P10"],
          ['P11', "P11"],
          ['P12', "P12"]
         ]),"tilt")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISTILT)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};




//磁簧开关传感器是否检测到磁场
Blockly.Blocks.motorDriverBoard_reed_switch = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/5.Magnetic   Switch.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_REEDSWITCH)
        .appendField(new Blockly.FieldDropdown([
          ['P1' , "P1" ],
          ['P2' , "P2" ],
          ['P3' , "P3" ],
          ['P4' , "P4" ],
          ['P9' , "P9" ],
          ['P10', "P10"],
          ['P11', "P11"],
          ['P12', "P12"]
         ]),"reedPort")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_ISREED)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
}
};

//超声波传感器读值
Blockly.Blocks.motorDriverBoard_ultrasonic = {
init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
   .appendField(new Blockly.FieldImage(staticImg+"/40.ph_ultrasonic.svg", 84, 42))
        .appendField(Blockly.Msg.MOTORDRIVERBOARD_ULTRASONIC)
        .appendField(new Blockly.FieldDropdown([
          ['P5', "P5"],
          ['P6', "P6"],
          ['P7', "P7"],
          ['P8', "P8"],
         ]),"ultrasonic")
         .appendField(Blockly.Msg.MOTORDRIVERBOARD_DISTANCE)
  this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
  this.setOutput(true, 'Number');
  this.setTooltip('');
}
};


//舵机
Blockly.Blocks.motorDriverBoard_servo = {
init:function(){
this.setColour(color_do);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/Servo.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_INITSERVOPIN)
   .appendField(new Blockly.FieldDropdown([
    ['D3', "3" ],
    ['D4', "4" ],
    ['10' , "10" ],
   ]),"phservopins")
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_SERVOANGLE)
   this.appendValueInput("phservoangle", Number)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};

//串口波特率
Blockly.Blocks.motorDriverBoard_serialbegin = {
init:function(){
this.setColour(color_serial);
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATE)
  .appendField(new Blockly.FieldDropdown([
  ['Serial', "Serial"],
  ['softwareSerial', "softwareSerial"],
]),"SerialS1")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATES)
  .appendField(new Blockly.FieldDropdown([
    ['4800', "4800"],
    ['9600', "9600"],
    ['38400', "38400"],
    ['57600', "57600"],
    ['115200', "115200"],
  ]),"serialbegins")
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//串口打印字符不换行
Blockly.Blocks.motorDriverBoard_serialprintstring = {
init:function(){
this.setColour(color_serial);
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATE)
    .appendField(new Blockly.FieldDropdown([
  ['Serial', "Serial"],
  ['softwareSerial', "softwareSerial"],
]),"SerialS22")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALPRINTSTRINGS)
   this.appendValueInput("serialprints1", String)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//串口打印字符
Blockly.Blocks.motorDriverBoard_serialprint = {
init:function(){
this.setColour(color_serial);
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATE)
    .appendField(new Blockly.FieldDropdown([
  ['Serial', "Serial"],
  ['softwareSerial', "softwareSerial"],
]),"SerialS2")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALPRINTSTRING)
   this.appendValueInput("serialprints", String)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//串口打印数字不换行
Blockly.Blocks.motorDriverBoard_serialprintnum1 = {
init:function(){
this.setColour(color_serial);
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATE)
    .appendField(new Blockly.FieldDropdown([
  ['Serial', "Serial"],
  ['softwareSerial', "softwareSerial"],
]),"SerialS33")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALPRINTNUMBERS)
   this.appendValueInput("serialprintsss", Number)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};



//串口打印数字
Blockly.Blocks.motorDriverBoard_serialprintnum = {
init:function(){
this.setColour(color_serial);
this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATE)
    .appendField(new Blockly.FieldDropdown([
  ['Serial', "Serial"],
  ['softwareSerial', "softwareSerial"],
]),"SerialS3")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALPRINTNUMBER)
   this.appendValueInput("serialprintss", Number)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//串口打印16进制
Blockly.Blocks.motorDriverBoard_serialprint16num = {
init:function(){
this.setColour(color_serial);
this.appendDummyInput("")
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_BAUDRATE)
     .appendField(new Blockly.FieldDropdown([
  ['Serial', "Serial"],
  ['softwareSerial', "softwareSerial"],
]),"SerialS4")
.appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALPRINTHEX)
    this.appendValueInput("serialprint16nums", Number)
this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
this.setTooltip('');
}
};





//串口有数据可读
Blockly.Blocks.motorDriverBoard_serialava = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_PORT)
  .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"SerialS")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALAVALIBLE)
     this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
  this.setOutput(true, 'Boolean');
  this.setTooltip('');
  }
  };
  //串口读取字节
  Blockly.Blocks.motorDriverBoard_serialread = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_PORT)
  .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"Serials")
     .appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALREAD)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
   this.setOutput(true, 'Number');
  this.setTooltip('');
  }
  };
  //串口读取整数小数
  Blockly.Blocks.motorDriverBoard_serialreadint = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_PORT)
  .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"Serials9")
     .appendField(Blockly.Msg.MOTORDRIVERBOARD_SERIALREADINTS)
     .appendField(new Blockly.FieldDropdown([
       [Blockly.Msg.MOTORDRIVERBOARD_SERIALREADINT, "parseInt()"],
       [Blockly.Msg.MOTORDRIVERBOARD_SERIALREADFLOAT, "parseFloat"],
     ]),"intfloat")
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
   this.setOutput(true, 'Number');
  this.setTooltip('');
  }
  };

  //软串口
Blockly.Blocks.motorDriverBoard_softserial = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_SOFTSERIAL_TX)
    .appendField(new Blockly.FieldDropdown([
      ['2', "2"],
      ['3', "3"],
      ['4', "4"],
      ['5', "5"],
      ['6', "6"],
      ['7', "7"],
      ['8', "8"],
      ['9', "9"],
      ['10', "10"],
      ['11', "11"],
      ['12', "12"],
      ['13', "13"],
      ['A0', "A0"],
      ['A1', "A1"],
      ['A2', "A2"],
      ['A3', "A3"],
      ['A4', "A4"],
      ['A5', "A5"],
    ]),"TX1")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_SOFTSERIAL_RX)
    .appendField(new Blockly.FieldDropdown([
      ['2', "2"],
      ['3', "3"],
      ['4', "4"],
      ['5', "5"],
      ['6', "6"],
      ['7', "7"],
      ['8', "8"],
      ['9', "9"],
      ['10', "10"],
      ['11', "11"],
      ['12', "12"],
      ['13', "13"],
      ['A0', "A0"],
      ['A1', "A1"],
      ['A2', "A2"],
      ['A3', "A3"],
      ['A4', "A4"],
      ['A5', "A5"],
    ]),"RX1")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_SOFTSERIALBAUDRATE)
    this.setPreviousStatement(true,null);
     this.setNextStatement(true,null);
    this.setTooltip('');
    }
    };
    //串口中断
  Blockly.Blocks.motorDriverBoard_serial_event = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_PORT)
  .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"Serials")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_INTERRUPUT);
     this.appendStatementInput('DO')
              .appendField(Blockly.Msg.MOTORDRIVERBOARD_DO);
          this.setPreviousStatement(true);
          this.setNextStatement(true);
          this.setTooltip('');
  }
  };
  //串口清空缓存区数据
  Blockly.Blocks.motorDriverBoard_serial_flush = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_PORT)
  .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"Serials")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_FLUSH);
          this.setPreviousStatement(true);
          this.setNextStatement(true);
          this.setTooltip('');
  }
  };
  //串口读取字符串
  Blockly.Blocks.motorDriverBoard_serial_read = {
  init:function(){
  this.setColour(color_serial);
  this.appendDummyInput("")
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_PORT)
  .appendField(new Blockly.FieldDropdown([
    ['Serial', "Serial"],
    ['softwareSerial', "softwareSerial"],
  ]),"Serials")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_READSTRING)
    this.appendValueInput("serialprints2", String)
         this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
      this.setOutput(true);
  this.setTooltip('');
  }
  };

//rgb超声波模块初始化
Blockly.Blocks.motorDriverBoard_rgbUltrasonicInit = {
init:function(){
 this.setColour(color_sensor);
 this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/52.RGB ultrasonic Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_ULTRASONICPIN)
     .appendField(new Blockly.FieldDropdown([
       ['P5', "P5"],
       ['P6', "P6"],
       ['P7', "P7"],
       ['P8', "P8"],
     ]),"motorDriverBoard_ulPINS")
     this.appendDummyInput("")
 this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
 this.setTooltip('');
}
};
//rgb超声波模块设置颜色样式
Blockly.Blocks.motorDriverBoard_rgbultrasonicsetcolorstyle = {
init:function(){
 this.setColour(color_sensor);
 this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/52.RGB ultrasonic Module.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBULTRASONICSETCOLOR)
     .appendField(new Blockly.FieldDropdown([
       [Blockly.Msg.MOTORDRIVERBOARD_ALL, "E_RGB_ALL"],
       [Blockly.Msg.MOTORDRIVERBOARD_LEFT, "E_RGB_LEFT"],
       [Blockly.Msg.MOTORDRIVERBOARD_RIGHT, "E_RGB_RIGHT"],
     ]),"motorDriverBoard_rgbultrasonicposition")
     this.appendDummyInput("")
     .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBULTRASONICSETCOLORLED)
     this.appendValueInput("COLOR", Number)
    this.appendDummyInput("")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBULTRASONICSTYLE)
         .appendField(new Blockly.FieldDropdown([
     [Blockly.Msg.MOTORDRIVERBOARD_NONE, "E_EFFECT_NONE"],
       [Blockly.Msg.MOTORDRIVERBOARD_BREATHING, "E_EFFECT_BREATHING"],
       [Blockly.Msg.MOTORDRIVERBOARD_ROTATE, "E_EFFECT_ROTATE"],
       [Blockly.Msg.MOTORDRIVERBOARD_FLASH, "E_EFFECT_FLASH"],
     ]),"motorDriverBoard_rgbultrasoniccolorstyle")
 this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
 this.setTooltip('');
}
};
//RGB超声波模块读取超声波距离
Blockly.Blocks.motorDriverBoard_rgbultrasonicreaddistance = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/52.RGB ultrasonic Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_RGBULTRASONICREADDISTANCE)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
   this.setOutput(true, 'Number');
  this.setTooltip('');
}
};

//4x4矩阵键盘初始化
Blockly.Blocks.motorDriverBoard_matrixKeyboardInit = {
init:function(){
 this.setColour(base_color);
 this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_MATRIXKEYBOARDINIT)
    .appendField(new Blockly.FieldDropdown([
       ['P5', "P5"],
       ['P6', "P6"],
       ['P7', "P7"],
       ['P8', "P8"],
    ]),"matrixKeyBoardPort")
 this.setPreviousStatement(true,null);
   this.setNextStatement(true,null);
 this.setTooltip('');
}
};

//4x4矩阵键盘
Blockly.Blocks.motorDriverBoard_matrixKeyboardFunc = {
init:function(){
 this.setColour(base_color);
 this.appendDummyInput("")
 .appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_BUTTONPUSHED)
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_KEYA, "A"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEYB, "B"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEYC, "C"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEYD, "D"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEYSTAR, "*"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEYAHASHTAG, "#"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY1, "1"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY2, "2"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY3, "3"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY4, "4"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY5, "5"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY6, "6"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY7, "7"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY8, "8"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY9, "9"],
      [Blockly.Msg.MOTORDRIVERBOARD_KEY0, "0"],
    ]),"motorDriverBoard_keyBoardValue")
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_STATUS)
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_PRESS, "press"],
      [Blockly.Msg.MOTORDRIVERBOARD_RELEASE, "release"],
      [Blockly.Msg.MOTORDRIVERBOARD_LONGPRESS, "holdDown"],
    ]),"motorDriverBoard_keyBoardCorrespondValue")  
    this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
    this.setOutput(true, 'Boolean');
    this.setTooltip('');
}
};

//获取矩阵键盘的值
Blockly.Blocks.motorDriverBoard_getMatrixKeyboardValue = {
init:function(){
this.setColour(base_color);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/49.Matrix Keyboard Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETMATRIXKEYBOARDVALUE)
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
   this.setOutput(true, 'String');
  this.setTooltip('');
}
};

//初始化ds1302  
Blockly.Blocks.motorDriverBoard_initds1302 = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DSINIT_RSTPIN)
   .appendField(new Blockly.FieldDropdown([
     ['P15', "P15"],
     ['P16', "P16"],
   ]),"ds1302Port")
    this.setPreviousStatement(true,null);
    this.setNextStatement(true,null);
this.setTooltip('');
}
};

//ds1302设置时分秒
Blockly.Blocks.motorDriverBoard_setds1302time = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DSSETTIME)
   this.appendValueInput("hour", Number)
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETHOUR)
   this.appendValueInput("minute", Number)
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETMINUTE)
   this.appendValueInput("second", Number)
   .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETSECOND)
this.setPreviousStatement(true,null);
 this.setNextStatement(true,null);
this.setTooltip('');
}
};
//ds1302设置年月日
Blockly.Blocks.motorDriverBoard_setds1302date = {
  init:function(){
  this.setColour(color_sensor);
  this.appendDummyInput("")
  .appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_DSSETDATE)
    this.appendValueInput("year", Number)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETYEAR)
    this.appendValueInput("month", Number)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETMONTH)
    this.appendValueInput("day", Number)
    .appendField(Blockly.Msg.MOTORDRIVERBOARD_GETDAY)
  this.setPreviousStatement(true,null);
  this.setNextStatement(true,null);
  this.setTooltip('');
  }
};

 //获取ds1302年月日时分秒
Blockly.Blocks.motorDriverBoard_getds1302date = {
init:function(){
this.setColour(color_sensor);
this.appendDummyInput("")
.appendField(new Blockly.FieldImage(staticImg+"/Clock Module.svg", 84, 42))
  .appendField(Blockly.Msg.MOTORDRIVERBOARD_DSGETDATE)
    .appendField(new Blockly.FieldDropdown([
      [Blockly.Msg.MOTORDRIVERBOARD_GETYEAR, "getYear"],
      [Blockly.Msg.MOTORDRIVERBOARD_GETMONTH, "getMonthStr"],
      [Blockly.Msg.MOTORDRIVERBOARD_GETDAY, "getDay"],
      [Blockly.Msg.MOTORDRIVERBOARD_GETHOUR, "getHour"],
      [Blockly.Msg.MOTORDRIVERBOARD_GETMINUTE, "getMinute"],
    [Blockly.Msg.MOTORDRIVERBOARD_GETSECOND, "getSecond"],
      [Blockly.Msg.MOTORDRIVERBOARD_GETWEEK, "getDOWStr"],
    ]),"DATES")
      this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
   this.setOutput(true, 'Number');
  this.setTooltip('');
}
};

























































































    return Blockly;
 }

module.exports = ArduinoUnoBlocks ;
